﻿using UnityEngine;
using System.Collections;

namespace MessageSystem
{
    /// <summary>
    /// 消息系统入口
    /// </summary>
    public class MessageSystemFacade : Singleton<MessageSystemFacade>,IInitable,IMassageManager
    {

        public void Init()
        {
            //InitDontDestroyObj("MessageManager", typeof(MessageManager));
        }

        #region 消息管理器

        IMassageManager messageManager = new MessageManager();

        /// <summary>
        /// 弹出一个消息终端
        /// </summary>
        /// <param name="go"></param>
        /// <returns></returns>
        public IMessageTerminal PopMessageTerimal(GameObject go)
        {
           return messageManager.PopMessageTerimal(go);
        }

        public IMessageTerminal GetMessageTerimalByID(int id)
        {
            throw new System.NotImplementedException();
        }

        public void RegisterMessage(string messageType, IMessageTerminal messageTerminal)
        {
            messageManager.RegisterMessage(messageType, messageTerminal);
        }

        /// <summary>
        /// 注销消息终端
        /// </summary>
        /// <param name="messageTerminal"></param>
        public void UnRegisterMessageTerminal(IMessageTerminal messageTerminal)
        {
            messageManager.UnRegisterMessageTerminal(messageTerminal);
        }

        /// <summary>
        /// 注销这个消息类型中的消息终端
        /// </summary>
        /// <param name="messageType"></param>
        /// <param name="messageTerminal"></param>
        public void UnRegisterMessage(string messageType, IMessageTerminal messageTerminal)
        {
            messageManager.UnRegisterMessage(messageType, messageTerminal);
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="messageType"></param>
        /// <param name="args"></param>
        public void SendMessage(string messageType, IMessageArgs args)
        {
            messageManager.SendMessage(messageType, args);
        }
        #endregion
    }
}

